package com.zhouyu.exampleThread.config;

import com.zhouyu.exampleThread.builder.ThreadPoolBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;

/**
 * @Description:调度线程池，如果你需要spring调度
 */
@Configuration
public class SchedulThreadPoolConfig implements SchedulingConfigurer {
  @Override
  public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
    scheduledTaskRegistrar.setTaskScheduler(threadPoolTaskScheduler());
  }

  @Bean
  public ThreadPoolTaskScheduler threadPoolTaskScheduler() {
    return ThreadPoolBuilder.builSchedulThreadPool();
  }
}
